<!--
  To change this template, choose Tools | Templates
  and open the template in the editor.
-->

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
  <head>
    <meta name="layout" content="main">
    <title>Facility - ${facility.name}</title>
  

  
  </head>
  
  <body>
    <div id="bd">
      
      <div id="facilityLeftSide">
        <div id="facilityAttributes">
          <h2><u>Attributes</u></h2></br>
          <g:each var="attr" in="${facility.facilityAttributes.sort{it.attribute.name}}">
            <table>
              <tr>
                <td>
                  <g:link controller="attribute" action="view" params="[name: attr.attribute.name]">
                            ${attr.attribute.name}</g:link>
                </td>
                <td style="padding-left: 10px">Rating: ${attr.getAverageRating()}</td>
                <td style="padding-left: 10px; padding-top: 15px">
                  <g:form action="rateAttribute">
                    <g:hiddenField name="facilityName" value="${facility.name}"/>
                    <g:hiddenField name="attrName" value="${attr.attribute.name}"/>
                    <g:select name="rating" from="${1..10}"></g:select>
                    <g:submitButton name="rate" value="Rate"/>
                  </g:form>
                </td>
              </tr>
            </table>
          </g:each>
          <g:link action="editAttributes" params="[name: facility.name]">Edit Attributes</g:link>
        </div>
        
        </br>
        </br>
        
        <div id="facilityForums">
          <h2><u>Forums</u></h2>
          <g:each var="forum" in="${forumList}" status="i">
              <g:link controller="Forum" action="view" params="[facilityName: forum.facility.name, topic: forum.topic]">${forum.topic}</g:link>
              </br>
          </g:each>
          </br>
          <g:link action="viewForums" params="[name: facility.name]">All Forums</g:link>
          </br></br>
          <g:link controller="Forum" action="createNew" params="[name: facility.name]">Create New Forum</g:link>
        </div>
      </div>
      
      <div id="facilityRightSide">
        <div id="facilityServices">
          <h2><u>Services</u></h2>
          <g:each var="service" in="${facility.facilitySvcs}">
            <g:link controller="FacilitySvc" action="view" 
                    params="[facilityName: facility.name, serviceName: service.name]">${service.name}</g:link>
            </br>
          </g:each>
          </br></br>
          <g:link controller="FacilitySvc" action="addNew"
                  params="[facilityName: facility.name]">Add New</g:link>
        </div>
        
        </br>
        </br>
        
        <div id="facilityGroups">
          <h2><u>Groups</u></h2>
          <g:each var="group" in="${facility.facilityGroups.sort{it.facilityGroup.groupName}}">
            <table>
              <tr>
                <td>
                  <g:link controller="FacilityGroup" action="view" params="[name: group.facilityGroup.groupName, facilityName: facility.name]">
                            ${group.facilityGroup.groupName}</g:link>
                </td>
              </tr>
            </table>
          </g:each>
          </br>
          <g:link action="editGroups" params="[name: facility.name]">Edit Groups</g:link>
        </div>
      </div>
      
      <div id="facilityInfo">
        <h1>${facility.name}</h1>
        <g:if test="${!facility.isInOperation}">
          <h1>This Facility Is Not In Operation</h1></br>
          </br>
        </g:if>
        <a>Type:  ${facility.facilityType}</a></br>
        <a>Latitude: ${facility.latitude}   Longitude: ${facility.longitude}</a></br>
        </br>
        <a><b>Address</b></a></br>
        <div id="addressInfo">
          <table>
            <tr>
              <td align="right">Address1:</td>
              <td style="padding-left: 10px">${facility?.primaryAddress?.address}</td>
            </tr>
            <tr>
              <td align="right">Address2:</td>
              <td style="padding-left: 10px">${facility?.primaryAddress?.address2}</td>
            </tr>
            <tr>
              <td align="right">LGA:</td>
              <td style="padding-left: 10px">${facility?.primaryAddress?.lga}</td>
            </tr>
            <tr>
              <td align="right">State:</td>
              <td style="padding-left: 10px">${facility?.primaryAddress?.state}</td>
            </tr>
          </table>
        </div>
        </br>
        <a><b>Graphic Location</b></a></br>
        <a>${facility?.facilitySite?.graphicLocation}</a></br>
        </br>
        <a><b>Mission Statement</b></a></br>
        <a>${facility?.facilitySite?.missionStatement}</a></br>
        </br>
        <a><b>Summary</b></a></br>
        <a>${facility?.facilitySite?.detail}</a></br>
        </br>
        <g:link action="editGeneralInfo" params="[name: facility.name]">Edit General Information</g:link>
        </br>
        </br>
        <a><b>Phone Numbers</b></a></br>
        <div id="phoneNumbers" align="center">
          <g:each var="number" in="${facility?.phones}">
            <table>
              <tr>
                <td align="right">${number.phoneType}:</td>
                <td style="padding-left: 10px">${number.number}</td>
              </tr>
            </table>
          </g:each>
          <g:link action="editNumbers" params="[name: facility.name]">Edit Phone Numbers</g:link>
        </div>
      </div>
      
     </div>
  </body>
</html>
